// 滚动监听
export default (callback) => {
  let timer
  function fnScroll() {
    if (timer) {
      clearTimeout(timer)
    }
    timer = setTimeout(() => {
      callback && callback(document.body.scrollTop || document.documentElement.scrollTop)
    }, 10)
  }
  return {
    mount() {
      window.addEventListener('scroll', fnScroll, false)
    },
    unmount() {
      window.removeEventListener('scroll', fnScroll, false)
    }
  }
}